﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace DwoDimensionArrays
{
    class Program
    {
        static void Main(string[] args)
        {

            int[,] testArray = CreateNewRandomDwoDimensionalArray(4, 5, 1, 10);
            PrintTwoDimensionalArray(testArray);
            Console.ReadKey();
        }

        static int[,] CreateNewRandomDwoDimensionalArray(int rowCount, int columnCount, int randomMinValue, int randomMaxValue)
        {
            int[,] newArray = new int[rowCount,columnCount];
            Random rnd = new Random();

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    newArray[i, j] = rnd.Next(randomMinValue, randomMaxValue+1);
                }
            }

            return newArray;
        }

        static void PrintTwoDimensionalArray(int[,] arrayForPrint)
        {
            for (int i = 0; i < arrayForPrint.GetLength(0); i++)
            {
                for (int j = 0; j < arrayForPrint.GetLength(1); j++)
                {
                    Console.Write("{0}\t", arrayForPrint[i, j]);
                }
                Console.WriteLine();
            }
        }
    }
}
